import Reflux from 'reflux';
import PageConst from './PageConst';
import Actions from './Actions';
import update from 'react-addons-update';

export default Reflux.createStore({
    listenables: [Actions],
    data: {
        ...PageConst,
      actshow: false,
      gallery: true,
      showMultiple: true,
      imgls:[]
    },

  loadMode: function (params) {
    let t = this;
    this.data.imgls = update(this.data.imgls, {$set: params});

    console.log('002');
    console.info(this.data.imgls);
    console.log('003');
    console.info(this.data.imgls.map(file=>file.url));

    t.updateComponent();
  },

  hidetp: function () {
    console.log('hidetp');
    this.data.gallery = update(this.data.gallery, {$set: false});
    console.log('hidetp_over');
    this.updateComponent();
  },

  initMode : function ( ) {
    this.data.actshow=false;
    this.data.gallery=true;
    this.data.showMultiple=true;
    //this.data.imgls.clear();
  },

    onFetch: function (params, cb) {
        let t = this;
        t.updateComponent();
        cb && cb(t.data);
    },

    updateComponent: function () {
        this.trigger(this.data);
    },

    getInitialState: function () {
        return this.data;
    }
});
